package com.uenpay.oem.ui.trans.receivable;

import android.content.Intent;
import android.text.InputFilter;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;

import com.uenpay.im.utilities.ToastUtil;
import com.uenpay.im.utilities.Toasts;
import com.uenpay.oem.R;
import com.uenpay.oem.widget.listener.AmountEditTextWatcher;
import com.uenpay.util.app.base.BaseActivity;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Author: liulou
 * Date: 2017/6/23.
 * desc:
 */

public class InputAmountActivity extends BaseActivity {

    @BindView(R.id.et_amount)
    EditText etAmount;
    @BindView(R.id.view_line)
    View viewLine;
    @BindView(R.id.et_msg)
    EditText etMsg;
    @BindView(R.id.ll_msg)
    LinearLayout llMsg;
    @BindView(R.id.btn_add_msg)
    Button btnAddMsg;
    @BindView(R.id.btn_confirm)
    Button btnConfirm;

    @Override
    public View bindView() {
        return null;
    }

    @Override
    public int bindLayout() {
        return R.layout.activity_qrcode_input_amount;
    }

    @Override
    public void initView(View view) {
        setTitle("收款");
        etAmount.addTextChangedListener(new AmountEditTextWatcher(etAmount));

    }

    @OnClick(R.id.btn_add_msg)
    public void addMsg() {
        viewLine.setVisibility(View.VISIBLE);
        llMsg.setVisibility(View.VISIBLE);
        btnAddMsg.setVisibility(View.GONE);
    }

    @OnClick(R.id.btn_confirm)
    public void confirm() {
        String amount = etAmount.getText().toString().trim();
        if (Double.valueOf(amount) <=0.0) {
            ToastUtil.showToast(getApplicationContext(), "金额不能小于0");
            return;
        }
        if (TextUtils.isEmpty(amount)) {
            Toasts.shortToast(this, "请输入金额");
            return;
        }
        Intent it = new Intent();
        it.putExtra("amount", amount);
        it.putExtra("msg", etMsg.getText().toString().trim());
        setResult(RESULT_OK, it);
        finish();
    }


}
